using mvcincode.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllersWithViews();
builder.Services.AddMyServices();


var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseStaticFiles();

app.UseRouting();

// app.MapGet("/hi", httpContext => {
//     return Task.FromResult(httpContext.GetEndpoint()?.DisplayName);
// }).RequireAuthorization();

var logger = app.Services.GetRequiredService<ILogger<Program>>();

// app.Use(async (httpContext, next) =>
// {
//     logger.LogInformation("middleware one before");
//     await next(httpContext);
//     logger.LogInformation("middleware one after");
// });

// app.Use(async (httpContext, next) =>
// {
//     logger.LogInformation("middleware two before");
//     await next(httpContext);
//     logger.LogInformation("middleware two after");
// });

// app.UseMyMiddleware();

app.UseAuthentication();

// app.UseMyAuthMiddleware();

app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");



app.Run();

